home *** CD-ROM | disk | FTP | other *** search
/ Champak 114 / Vol 114.iso / games / park_thi.swf / scripts / DefineSprite_150_clip14 / frame_1 / DoAction.as < prev   
Encoding:
Text File  |  2010-08-12  |  2.1 KB  |  72 lines

  1. function attack()
  2. {
  3.    var _loc4_ = _parent.attachMovie("bomb","bomb" + _parent.getNextHighestDepth(),_parent.getNextHighestDepth());
  4.    _loc4_.angle = this._rotation;
  5.    _parent.globalToLocal(point);
  6.    trace(point.x);
  7.    _loc4_._x = point.x;
  8.    _loc4_._y = point.y;
  9.    _loc4_.target = target;
  10.    range = _root.randomRange(120,190);
  11.    _loc4_.onEnterFrame = function()
  12.    {
  13.       this._x -= 10 * Math.cos(this.angle * 3.141592653589793 / 180);
  14.       this._y -= 10 * Math.sin(this.angle * 3.141592653589793 / 180);
  15.       this._rotation = this.angle + 90;
  16.       range -= 10;
  17.       if(range <= 0)
  18.       {
  19.          var _loc3_ = _parent.blast_mc.attachMovie("blast","blast" + _parent.blast_mc.getNextHighestDepth(),_parent.blast_mc.getNextHighestDepth());
  20.          _loc3_._x = this._x;
  21.          _loc3_._y = this._y;
  22.          _loc3_._xscale = _loc3_._yscale = 30;
  23.          this.removeMovieClip();
  24.       }
  25.       if(this._x > 400 || this._x < -400 || this._y < -300 || this._y > 300)
  26.       {
  27.          this.removeMovieClip();
  28.       }
  29.       if(this.hitTest(target))
  30.       {
  31.          target.health -= 20;
  32.          _loc3_ = _parent.blast_mc.attachMovie("blast","blast" + _parent.blast_mc.getNextHighestDepth(),_parent.blast_mc.getNextHighestDepth());
  33.          _loc3_._x = this._x;
  34.          _loc3_._y = this._y;
  35.          _loc3_._xscale = _loc3_._yscale = 30;
  36.          this.removeMovieClip();
  37.       }
  38.    };
  39. }
  40. var target;
  41. var attackRate = 25;
  42. var timer = 0;
  43. var health = 100;
  44. var range = 150;
  45. onEnterFrame = function()
  46. {
  47.    if(_root.userCar == "")
  48.    {
  49.       target = _parent.valet_mc;
  50.    }
  51.    else
  52.    {
  53.       target = _parent[_root.userCar];
  54.    }
  55.    this._rotation = Math.atan2(this._y - target._y,this._x - target._x) * 180 / 3.141592653589793;
  56.    if(_currentframe == 1)
  57.    {
  58.       gotoAndStop(3);
  59.    }
  60.    if(_root.userCar != "")
  61.    {
  62.       if(this.hitTest(target) && this._currentframe != _totalframes)
  63.       {
  64.          this.health -= 20;
  65.          if(this.health <= 0)
  66.          {
  67.             this.gotoAndStop(_totalframes);
  68.          }
  69.       }
  70.    }
  71. };
  72.